﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;

namespace TjZheng.News.Process
{
    public partial class BaseController
    {
        /// <summary>
        /// 获取评论列表
        /// </summary>
        /// <param name="categoryId"></param>
        /// <param name="articleId">文章Id</param>
        /// <param name="commentID"></param>
        /// <param name="position"></param>
        /// <param name="loadCount"></param>
        /// <param name="isLoadFloor"></param>
        /// <returns></returns>
        [OutputCache(Duration = 5)]
        public virtual JsonResult GetCommentList(int? categoryId, int? articleId, int? commentID, string position, int? loadCount = 10, int? isLoadFloor = 0)
        {
            return Json(CurrentProcess.GetCommentList(categoryId, articleId, commentID, position, loadCount, isLoadFloor), JsonRequestBehavior.AllowGet);
        }
        /// <summary>
        /// 获取热门评论
        /// </summary>
        /// <param name="categoryId"></param>
        /// <param name="articleId"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="isLoadFloor"></param>
        /// <returns></returns>
        [OutputCache(Duration = 5)]
        public virtual JsonResult GetCommentHotList(int? categoryId, int? articleId, int? pageIndex = 1, int? pageSize = 10, int? isLoadFloor = 0)
        {
            return Json(CurrentProcess.GetCommentHotList(categoryId, articleId, pageIndex, pageSize, isLoadFloor), JsonRequestBehavior.AllowGet);
        }
        /// <summary>
        /// 获取评论列表
        /// </summary>
        /// <param name="categoryId"></param>
        /// <param name="articleId">文章Id</param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="isLoadFloor"></param>
        /// <returns></returns>
        [OutputCache(Duration = 5)]
        public virtual JsonResult GetCommentPageList(int? categoryId, int? articleId, int? pageIndex = 1, int? pageSize = 10, int? isLoadFloor = 0)
        {
            return Json(CurrentProcess.GetCommentPageList(categoryId, articleId, pageIndex, pageSize, isLoadFloor), JsonRequestBehavior.AllowGet);
        }
        /// <summary>
        /// 展开评论楼层列表
        /// </summary>
        /// <param name="categoryId"></param>
        /// <param name="commentId"></param>
        /// <param name="previousReplyId"></param>
        /// <param name="lastReplyId"></param>
        /// <param name="floorCount"></param>
        /// <returns></returns>
        [OutputCache(Duration = 5)]
        public virtual JsonResult GetCommentRestFloorList(int? categoryId, int? commentId, int? previousReplyId, int? lastReplyId, int? floorCount = 50)
        {
            return Json(CurrentProcess.GetCommentRestFloorList(categoryId, commentId, previousReplyId, lastReplyId, floorCount), JsonRequestBehavior.AllowGet);
        }
        /// <summary>
        /// 轮询是否有最新评论
        /// </summary>
        /// <param name="categoryId"></param>
        /// <param name="articleId"></param>
        /// <param name="commentID"></param>
        /// <returns></returns>
        public virtual JsonResult HasCommentLatest(int categoryId, int? articleId, int? commentID)
        {
            return Json(CurrentProcess.HasCommentLatest(categoryId, articleId, commentID), JsonRequestBehavior.AllowGet);
        }
        /// <summary>
        /// 添加评论
        /// </summary>
        /// <param name="parentId"></param>
        /// <param name="categoryId"></param>
        /// <param name="articleId"></param>
        /// <param name="replyId"></param>
        /// <param name="userId"></param>
        /// <param name="userName"></param>
        /// <param name="avatar"></param>
        /// <param name="content"></param>
        /// <returns></returns>
        [HttpPost]
        [ValidateInput(false)]
        public virtual JsonResult AddComment(int? parentId, int? categoryId, int? articleId, int? replyId, string userId, string userName, string avatar, string content)
        {
            return Json(CurrentProcess.AddComment(parentId, categoryId, articleId, replyId, userId, userName, avatar, content));
        }
        /// <summary>
        /// 评论点赞
        /// </summary>
        /// <param name="categoryId"></param>
        /// <param name="commentId"></param>
        /// <returns></returns>
        public virtual JsonResult DiggComment(int? categoryId, int? commentId)
        {
            return Json(CurrentProcess.DiggComment(categoryId, commentId), JsonRequestBehavior.AllowGet);
        }
    }
}
